/**
 */
package de.thwildau.tm.moses.asn1.asn1.impl;

import de.thwildau.tm.moses.asn1.asn1.Asn1Package;
import de.thwildau.tm.moses.asn1.asn1.LowerEndpoint;
import de.thwildau.tm.moses.asn1.asn1.UpperEndpoint;
import de.thwildau.tm.moses.asn1.asn1.ValueRange;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Value Range</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ValueRangeImpl#getLowerEndpoint <em>Lower Endpoint</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ValueRangeImpl#getUpperEndpoint <em>Upper Endpoint</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ValueRangeImpl extends SubtypeElementsImpl implements ValueRange
{
  /**
   * The cached value of the '{@link #getLowerEndpoint() <em>Lower Endpoint</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLowerEndpoint()
   * @generated
   * @ordered
   */
  protected LowerEndpoint lowerEndpoint;

  /**
   * The cached value of the '{@link #getUpperEndpoint() <em>Upper Endpoint</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUpperEndpoint()
   * @generated
   * @ordered
   */
  protected UpperEndpoint upperEndpoint;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ValueRangeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Asn1Package.Literals.VALUE_RANGE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public LowerEndpoint getLowerEndpoint()
  {
    return lowerEndpoint;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetLowerEndpoint(LowerEndpoint newLowerEndpoint, NotificationChain msgs)
  {
    LowerEndpoint oldLowerEndpoint = lowerEndpoint;
    lowerEndpoint = newLowerEndpoint;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.VALUE_RANGE__LOWER_ENDPOINT, oldLowerEndpoint, newLowerEndpoint);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setLowerEndpoint(LowerEndpoint newLowerEndpoint)
  {
    if (newLowerEndpoint != lowerEndpoint)
    {
      NotificationChain msgs = null;
      if (lowerEndpoint != null)
        msgs = ((InternalEObject)lowerEndpoint).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.VALUE_RANGE__LOWER_ENDPOINT, null, msgs);
      if (newLowerEndpoint != null)
        msgs = ((InternalEObject)newLowerEndpoint).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.VALUE_RANGE__LOWER_ENDPOINT, null, msgs);
      msgs = basicSetLowerEndpoint(newLowerEndpoint, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.VALUE_RANGE__LOWER_ENDPOINT, newLowerEndpoint, newLowerEndpoint));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public UpperEndpoint getUpperEndpoint()
  {
    return upperEndpoint;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetUpperEndpoint(UpperEndpoint newUpperEndpoint, NotificationChain msgs)
  {
    UpperEndpoint oldUpperEndpoint = upperEndpoint;
    upperEndpoint = newUpperEndpoint;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.VALUE_RANGE__UPPER_ENDPOINT, oldUpperEndpoint, newUpperEndpoint);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setUpperEndpoint(UpperEndpoint newUpperEndpoint)
  {
    if (newUpperEndpoint != upperEndpoint)
    {
      NotificationChain msgs = null;
      if (upperEndpoint != null)
        msgs = ((InternalEObject)upperEndpoint).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.VALUE_RANGE__UPPER_ENDPOINT, null, msgs);
      if (newUpperEndpoint != null)
        msgs = ((InternalEObject)newUpperEndpoint).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.VALUE_RANGE__UPPER_ENDPOINT, null, msgs);
      msgs = basicSetUpperEndpoint(newUpperEndpoint, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.VALUE_RANGE__UPPER_ENDPOINT, newUpperEndpoint, newUpperEndpoint));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Asn1Package.VALUE_RANGE__LOWER_ENDPOINT:
        return basicSetLowerEndpoint(null, msgs);
      case Asn1Package.VALUE_RANGE__UPPER_ENDPOINT:
        return basicSetUpperEndpoint(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Asn1Package.VALUE_RANGE__LOWER_ENDPOINT:
        return getLowerEndpoint();
      case Asn1Package.VALUE_RANGE__UPPER_ENDPOINT:
        return getUpperEndpoint();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Asn1Package.VALUE_RANGE__LOWER_ENDPOINT:
        setLowerEndpoint((LowerEndpoint)newValue);
        return;
      case Asn1Package.VALUE_RANGE__UPPER_ENDPOINT:
        setUpperEndpoint((UpperEndpoint)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.VALUE_RANGE__LOWER_ENDPOINT:
        setLowerEndpoint((LowerEndpoint)null);
        return;
      case Asn1Package.VALUE_RANGE__UPPER_ENDPOINT:
        setUpperEndpoint((UpperEndpoint)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.VALUE_RANGE__LOWER_ENDPOINT:
        return lowerEndpoint != null;
      case Asn1Package.VALUE_RANGE__UPPER_ENDPOINT:
        return upperEndpoint != null;
    }
    return super.eIsSet(featureID);
  }

} //ValueRangeImpl
